import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-05-05
 * Time: 15:34
 */
public class Solution {
    public static void moveZeroes(int[] nums) {
        int i=0;
        int j=1;
        if(nums.length==1){

            return ;
        }
        int n=nums.length;
        while(i<n&&nums[i]!=0){
            i++;
        }
        j=i+1;
        while(j<n){
            if(nums[j]!=0){
                nums[i++]=nums[j++];
            }else{
                j++;
            }
        }
        while(i<n){
            nums[i]=0;
            i++;
        }

    }
    public static int[] plusOne(int[] digits) {
        int n = digits.length;
        for (int i = n - 1; i >= 0; --i) {
            if (digits[i] != 9) {
                ++digits[i];
                for (int j = i + 1; j < n; ++j) {
                    digits[j] = 0;
                }
                return digits;
            }
        }

        // digits 中所有的元素均为 9
        int[] ans = new int[n + 1];
        ans[0] = 1;
        return ans;

    }

    public static void main(String[] args) {
        int[] nums={2,1};
        moveZeroes(nums);
        System.out.println(Arrays.toString(nums));
    }
    public static void main1(String[] args) {
        int[] arr1={8,9,9,9};
        int[] arr2=plusOne(arr1);
        System.out.println(Arrays.toString(arr2));
    }
}
